package openmind.demo.filterUsage;

import openmind.demo.Employee;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author wangzhuangzhuang
 * @DESC:
 * @date 2022-01-06 10:41
 */
public class StreamFilterPredicate {

	public static void main(String[] args) {
		Employee emp01 = new Employee(1, 23, "M", "Rick", "Beethovan");
		Employee emp02 = new Employee(2, 13, "F", "Martina", "Hengis");
		Employee emp03 = new Employee(3,43,"M","Ricky","Martin");
		Employee emp04 = new Employee(4,26,"M","Jon","Lowman");
		Employee emp05 = new Employee(5,19,"F","Cristine","Maria");
		Employee emp06 = new Employee(6,15,"M","David","Feezor");
		Employee emp07 = new Employee(7,68,"F","Melissa","Roy");
		Employee emp08 = new Employee(8,79,"M","Alex","Gussin");
		Employee emp09 = new Employee(9,15,"F","Neetu","Singh");
		Employee emp010 = new Employee(10,45,"M","Naveen","Jain");

		List<Employee> employees = Arrays.asList(emp01, emp02, emp03, emp04, emp05, emp06, emp07, emp08, emp09, emp010);

		List<Employee> filteredEmployees = employees.stream()
				.filter(e -> e.getAge() > 70 && "M".equals(e.getGender()))
				.collect(Collectors.toList());
		System.out.println(filteredEmployees); // [Employee(id=8, age=79, gender=M, firstName=Alex, lastName=Gussin)]
	}
}